import { IncomingHttpHeaders } from 'http';

import count from '@dfeidao/atom-nodejs/db/count';
import query from '@dfeidao/atom-nodejs/db/query';
import { productid, systemid } from '../../atom/config';
interface Message {
	test: string;
	// cookie: {
	// 	uk: string;
	// 	[key: string]: string
	// };
	// urls: {
	// 	base: string;
	// 	origin: string;
	// 	url: string;
	// };
	// query: {};
	// params: {};
	// headers: {};
	// captcha: string;
}
export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	const P = query(action_id, session_id, systemid);
	P.prepare('question_bank', ['question_no', 'right_answer'], { productid, topic_type: '单选题' }, 10, 1, [], []);
	const [dt] = await P.exec();
	const A = count(action_id, session_id, systemid);
	A.prepare('question_bank', { productid, topic_type: '单选题' });
	const [c] = await A.exec();

	const P1 = query(action_id, session_id, systemid);
	P1.prepare('question_bank', ['question_no'], { productid, topic_type: '多选题' }, 5, 1, [], []);
	const [dt1] = await P1.exec();
	const A1 = count(action_id, session_id, systemid);
	A1.prepare('question_bank', { productid, topic_type: '多选题' });
	const [c1] = await A1.exec();

	const P2 = query(action_id, session_id, systemid);
	P2.prepare('question_bank', ['question_no'], { productid, topic_type: '判断题' }, 10, 1, [], []);
	const [dt2] = await P2.exec();
	const A2 = count(action_id, session_id, systemid);
	A2.prepare('question_bank', { productid, topic_type: '判断题' });
	const [c2] = await A2.exec();
	return { dt, c, dt1, c1, dt2, c2 };
}
